<?php

namespace App\Http\Controllers\Home;

use App\Http\Model\Article;
use Illuminate\Http\Request;

class IndexController extends CommonController
{
    /**
     * 前台首页
     */
    public function index()
    {
        $news = Article::where('cate_id', 1)->orderBy('art_time', 'desc')->paginate(5);
        $state = Article::where('cate_id', 2)->orderBy('art_time', 'desc')->paginate(5);
        $subject = Article::where('cate_id', 3)->orderBy('art_time', 'desc')->paginate(5);
        return view('home.index', compact('news', 'state', 'subject'));
    }

    /**
     * 公司简介
     */
    public function company()
    {
        return view('home.company');
    }

    /**
     * 新闻列表
     */
    public function newslist()
    {
        $news = Article::where('cate_id', 1)->orderBy('art_time', 'desc')->paginate(8);
        $state = Article::where('cate_id', 2)->orderBy('art_time', 'desc')->paginate(8);
        $subject = Article::where('cate_id', 3)->orderBy('art_time', 'desc')->paginate(8);
        return view('home/newslist', compact('news', 'state', 'subject'));
    }

    /**
     * 新闻详情
     */
    public function new($art_id)
    {
        $data = Article::find($art_id);
        $article['pre'] = Article::where('art_id', '<', $art_id)->orderBy('art_id', 'desc')->first();
        $article['next'] = Article::where('art_id', '>', $art_id)->orderBy('art_id', 'asc')->first();

        return view('home/new', compact('data', 'article'));
    }

    /**
     * 项目列表
     */
    public function items()
    {
        return view('home/items');
    }

    /**
     * 项目祥情
     */
    public function project()
    {
        return view('home/project');
    }

    /**
     *联系我们
     */
    public function contact()
    {
        return view('home/contact');
    }

//    在线留言
    public function online()
    {
        return view('home/online');
    }

    public function photo()
    {
        return view('home/photo');
    }
}
